<?php

/**
 * Well Framework
 * 
 * Contains Front Controller pattern class
 *
 * @package    Well 
 * 
 * @author     Valerii Lazarevych <valeriy.fremar@gmail.com>
 */

/**
 * Abstract class Registy
 * 
 * @abstract
 */
class ApplicationRegistry     //extends ArrayObject
{
    /**
     * Storage elements of registry
     * 
     * @var mixed 
     */
    private  $values    =   array();
    
    /**
     * Registry object provides storage for shared objects
     * 
     * @var Registry 
     */
    private static $instance;        
    
    /**
     * Abstract Constructor
     */
    private function __construct(){}
    
    /**
     * Return instance of singlton registry
     * @return Registry
     */
    private static function instance()
    {
        if (!self::$instance){            
             self::$instance = new self();
        }        
        return self::$instance;
    }            
    
    /**
     * Get element from Registry     
     * @param string $key
     */
    static public function get( $key )
    {
        if ( isset( self::instance()->values[$key]) ){
            return  self::instance()->values[$key];
        }        
        return null;
    }
    
    /**
     * Set element to the Registry
     * 
     * @param string $key
     * @param mixed $val 
     */
    static public function set( $key, $val )
    {
        self::instance()->values[$key] =   $val;
    }                       
}
?>
